<html>
<head> 
<meta http-equiv="refresh" content="5;url=/"> 
</head>
<body>
<?php 
header("Content-type: text/html; charset=utf-8");
function DBupdate($host,$stat){
	$host=trim($host);
	$stat=trim($stat);
	echo $host."<br>";
	header("Content-type: text/html; charset=utf-8");
	$con = mysql_connect("113.215.1.161","root","root");
	if (!$con)
  	{
  	die('Could not connect: ' . mysql_error());
  	}
	//code
	mysql_select_db("mydb", $con);//选库
	mysql_query("set names 'utf8'");
	$res=mysql_query("SELECT * FROM govTab WHERE host='$host'");
	if (!mysql_num_rows($res)) 
	{
		echo "该网站不存在<br>";
	}
	else
	{
		mysql_query("UPDATE govTab SET mon='$stat' WHERE host='$host'");#修改为no
		echo "完成修改！<br>";
		$res=mysql_query("SELECT * FROM govTab WHERE host='$host'");#再次查询
		$row = mysql_fetch_array($res, MYSQL_ASSOC);
		echo $row['host']."监控状态为：".$row['mon'];
		mysql_close($con);
	}
	
}

$stat=$_POST["stat"];
$hosts=$_POST["host"];

foreach ($hosts as $host) {
	DBupdate($host,$stat);
}
echo "<br>5秒后回到页面";

?>
</body>
</html>